HTMLify
index.html
Views: 400 | Author: cody
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | <!DOCTYPE html> <html> <head> <meta charset='utf-8'> <meta http-equiv='X-UA-Compatible' content='IE=edge'> <title>Colorful Ripple Effect</title> <meta name='viewport' content='width=device-width, initial-scale=1'> <link rel='stylesheet' type='text/css' media='screen' href='style.css'> </head> <body> <a href="#" class="btn">Click Me</a> <script> let btn = document.querySelectorAll(".btn"); btn.forEach((btn) => { btn.onclick = function (e) { let x = e.pageX - e.target.offsetLeft; let y = e.pageY - e.target.offsetTop; let color = "#" + Math.floor(Math.random() * 0xffffff).toString(16); let ripples = document.createElement("span"); ripples.style.left = x + "px"; ripples.style.top = y + "px"; ripples.style.borderColor = color; this.appendChild(ripples); setTimeout(() => { ripples.remove(); }, 2000); }; }); </script> </body> </html> |